package com.sskj.base.utils;

import android.annotation.SuppressLint;
import android.view.View;

import com.jakewharton.rxbinding2.view.RxView;

import java.util.concurrent.TimeUnit;

public class ClickUtil {

    @SuppressLint("CheckResult")
    public static void click(View view, Click click) {
        RxView.clicks(view)
                .throttleFirst(800, TimeUnit.MILLISECONDS)
                .subscribe(aVoid -> click.click(view), Throwable::printStackTrace);
    }

    @SuppressLint("CheckResult")
    public static void click(long time, View view, Click click) {
        RxView.clicks(view)
                .throttleFirst(time, TimeUnit.MILLISECONDS)
                .subscribe(aVoid -> click.click(view), Throwable::printStackTrace);
    }

    public interface Click {
        void click(View view);
    }
}
